﻿using System;
using System.Threading;
using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LEDHelper;
using System.Runtime.InteropServices;

namespace LEDManager
{

    public partial class LEDConsole2
    {
        Int32 ConvertEffect(int nEffectType)
        {
            /*
      method: 显示方式
       * 1.   立即显示 2.   左滚显示    3.   连续上滚   4.   中间向上下展开   5.   中间向两边展开   6.   中间向四周展开   7.   向左移入
       * 8.   向右移入   9.   从左向右展开  10.   从右向左展开  11.   右上角移入  12.   右下角移入  13.   左上角移入  14.   左下角移入
       * 15.   从上向下移入  16.   从下向上移入  17.   闪  烁
       * speed:   显示速度（1-8）越大越快
       * transparent: 是否透明   0=不透明 1=透明
             *                 //上滚文字=4
              LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("上滚文字,x=10,y=2,宽=128,高=32,速度=1", 10, 2, 128, 32, 4, 1);
                //下滚文字=16
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("下滚文字", 10, 2, 128, 32, 16, 1); 
             
      */
            int method = 1;
            switch (nEffectType)
            {
             case 0:
                    method = 1;
                    break;
                case 1:
                    method = 2;
                    break;
                case 2:
                    method = 9;
                    break;
                case 3:
                    method = 16;
                    break;
                case 4:
                    method = 4;
                    break;
                case 5:
                    method = 5;
                    break; 
                default:
                    //method = nEffectType;
                    break;
            }
            return method;
        }
        Int32 ConvertSpeed(int nSpeed)
        {
            int speed = 1;
            switch (nSpeed)
            {
                case 1:
                default:
                    speed = nSpeed;
                    break;
            }
            if (speed > 7)
                speed = 7;
            return speed;
        }
        Int32 ConvertBright(int iValue)
        {
            int bright = 7;
            switch (iValue)
            {
                case 1:
                default:
                    bright = iValue;
                    break;
            }
            if (bright > 7)
                bright = 7;
            return bright;
        }
        Int32 ConvertTrasnparent(int lTrasnparent)
        {
            int transparent = 0;
            switch (lTrasnparent)
            {
                case 1:
                default:
                    transparent = lTrasnparent;
                    break;
            }
            return transparent;
        }
        int sleep = 200;
        //外部向中心请求，中心定位到对应的显示屏，向该显示屏请求。

        LEDUnit2 GetLED(int nLEDID)
        {
            LEDUnit2 led = null;
            try
            {
                foreach (KeyValuePair<string, LEDUnit2> kp in ledList)
                {
                    LEDUnit2 ledtemp = (LEDUnit2)kp.Value;
                    if (ledtemp.ledid == nLEDID)
                        led = ledtemp;
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return led;
        }
        #region=============System===================
        public object LED_GetLEDList()
        {
            object result = GetLEDList();
            return result;
        }
        public object ResetLedData()
        {
            object result =null; 
            try
            {
                result = (object)PerformCommand("ResetLedData");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_Registration(int nLEDID, string Lprefix, string Lnumber, string ip, string mac, string devtyp, string bit, string locport, string comport, string stype,
            string rmtport, string dstAdd, string Lwidth, string Lheight,string nuser,string ndate,string cuser,string cdate)
        {
            object result = null;
            try
            {
                //result = (object)PerformCommand("LED_Registration", nLEDID, Lprefix, Lnumber, mac, ip, devtyp, bit, locport, comport, stype, rmtport, dstAdd, Lwidth, Lheight, nuser, ndate, cuser,cdate);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;

            /*  result = led.LED_Registration(nLEDID, Lprefix, Lnumber, mac, width, ip, devtyp, bit, locport, comport, stype, rmtport, dstAdd, Lwidth, Lheight, nuser, ndate, cuser.cdate);
                 break;         
             * public void LED_Registration(int nLEDID,string prefix,string number,string ip,string mac,string devtyp,string bit,string locport,string comport,string stype,
            string rmtport,string dstAdd,string width,string height)
        { 
          
        
        }*/
    }
        public object XLED_Startup()
        {
            object result =null; 
            try
            {
                result = (object)PerformCommand("LED_Startup");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object XLED_Cleanup()
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Cleanup");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object XLED_Report_CreateServer(Int32 serverindex, Int32 localport)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_CreateServer", serverindex, localport);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object XLED_Report_RemoveServer(Int32 serverindex)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_CreateServer", serverindex);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //删除全部控制卡在线监听服务 
        public object XLED_Report_RemoveAllServer()
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_RemoveServer");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        
        
        //获得控制卡在线列表
        //必须先创建控制卡在线监听服务，即调用LED_Report_CreateServer后使用，否则返回值无效
        //  serverindex 控制卡在线监听服务编号
        //  plist 输出在线列表的用户外部缓冲区，
        //        如果传入空(NULL/0)，则输出到动态链接库内部的缓冲区，继续调用下面的接口取得详细信息
        //  count 最大读取个数
        //--返回值-- 小于0表示失败(未创建该在线监听服务)，大于等于0表示在线的控制卡数量

        public object XLED_Report_GetOnlineList(Int32 serverindex, Int32 listaddr, Int32 count)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_GetOnlineList", serverindex, listaddr, count);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //获得某个在线控制卡的上报控制卡名称
        //必须先创建控制卡在线监听服务，即调用LED_Report_CreateServer后使用，否则返回值无效
        //  serverindex 控制卡在线监听服务编号
        //  itemindex 该监听服务的在线列表中，在线控制卡的编号
        //--返回值-- 在线控制卡的上报控制卡名称

        public object XLED_Report_GetOnlineItemName(Int32 serverindex, Int32 itemindex)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_GetOnlineItemName", serverindex, itemindex);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //获得某个在线控制卡的上报控制卡IP地址
        //必须先创建控制卡在线监听服务，即调用LED_Report_CreateServer后使用，否则返回值无效
        //  serverindex 控制卡在线监听服务编号
        //  itemindex 该监听服务的在线列表中，在线控制卡的编号
        //--返回值-- 在线控制卡的IP地址

        public object XLED_Report_GetOnlineItemHost(Int32 serverindex, Int32 itemindex)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_GetOnlineItemHost", serverindex, itemindex);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }


        //获得某个在线控制卡的上报控制卡远程UDP端口号
        //必须先创建控制卡在线监听服务，即调用LED_Report_CreateServer后使用，否则返回值无效
        //  serverindex 控制卡在线监听服务编号
        //  itemindex 该监听服务的在线列表中，在线控制卡的编号
        //--返回值-- 在线控制卡的远程UDP端口号

        public object XLED_Report_GetOnlineItemPort(Int32 serverindex, Int32 itemindex)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_GetOnlineItemPort", serverindex, itemindex);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //获得某个在线控制卡的上报控制卡地址
        //必须先创建控制卡在线监听服务，即调用LED_Report_CreateServer后使用，否则返回值无效
        //  serverindex 控制卡在线监听服务编号
        //  itemindex 该监听服务的在线列表中，在线控制卡的编号
        //--返回值-- 在线控制卡的硬件地址

        public object XLED_Report_GetOnlineItemAddr(Int32 serverindex, Int32 itemindex)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_Report_GetOnlineItemAddr", serverindex, itemindex);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object XLED_CloseDeviceOnTerminate(int AValue)
        {
            object result = null;
            try
            {
                result = (object)PerformCommand("LED_CloseDeviceOnTerminate", AValue);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //取得控制卡IP地址 
        public object XLED_Cache_GetBoardParam_IP()
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_GetBoardParam_IP");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
       
        //取得控制卡MAC地址
        public object XLED_Cache_GetBoardParam_Mac()
        {
            object result = 0;            
            try
            {
                result = (object)PerformCommand("LED_Cache_GetBoardParam_Mac");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //取得控制卡设备地址

        public object XLED_Cache_GetBoardParam_Addr()
        {
            object result = 0;            
            try
            {
                result = (object)PerformCommand("LED_Cache_GetBoardParam_Addr");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //取得控制卡设备宽度
        public object XLED_Cache_GetBoardParam_Width()
        {
           object result = 0;            
            try
            {
                result = (object)PerformCommand("LED_Cache_GetBoardParam_Width");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //取得控制卡设备高度
        public object XLED_Cache_GetBoardParam_Height()
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_GetBoardParam_Height");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //取得控制卡设备亮度
        public object XLED_Cache_GetBoardParam_Brightness()
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_GetBoardParam_Brightness");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡IP地址
        public object XLED_Cache_SetBoardParam_IP(String value)
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_SetBoardParam_IP", value);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡MAC地址
        public object XLED_Cache_SetBoardParam_Mac(String value)
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_SetBoardParam_Mac", value);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡设备地址
        public object XLED_Cache_SetBoardParam_Addr(Int32 value)
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_SetBoardParam_Addr", value);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡设备宽度
        public object XLED_Cache_SetBoardParam_Width(Int32 value)
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_SetBoardParam_Width", value);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡设备高度
        public object XLED_Cache_SetBoardParam_Height(Int32 value)
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_SetBoardParam_Height", value);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡设备亮度
        public object XLED_Cache_SetBoardParam_Brightness(Int32 value)
        {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_SetBoardParam_Brightness", value);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object XLED_Cache_SetBoardParam2(Int32 param_index)
            {
            object result = 0;
            try
            {
                result = (object)PerformCommand("LED_Cache_SetBoardParam2", param_index);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        #endregion
        //预览显示内容
        public object LED_Preview(Int32 index, Int32 width, Int32 height, string previewfile)
        {
            int nLEDID = 1;
            object result = null;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_Preview", index, width, height, previewfile);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置每次命令执行完成后，是否关闭设备。=0表示不关闭；=1表示关闭。
        //获取控制卡应答结果的数据

        public object LED_GetNotifyParam(int nLEDID, Int32 index)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_GetNotifyParam", index);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;

        }
        public object LED_PreviewFile(int nLEDID,Int32 width, Int32 height, string previewfile)
        {
            object result = null;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_PreviewFile", width, height, previewfile);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_ResetDisplay(int nLEDID)
         {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_ResetDisplay");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;

        }
        //重启控制卡
        public object LED_Reboot(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_Reboot");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;

        }
        //读取控制卡温湿度值
        public object LED_GetTemperatureHumidity(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_GetTemperatureHumidity");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡电源 value=LED_POWER_ON表示开启电源 value=LED_POWER_OFF表示关闭电源
        public object LED_SetPower(int nLEDID, Int32 value,int iOutpuIP)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_SetPower", value, iOutpuIP);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //读取控制卡电源状态
        public object LED_GetPower(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_GetPower");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡亮度 value取值范围0-7
        public object LED_SetBright(int nLEDID, Int32 value)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_SetBright", value);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //读取控制卡亮度
        public object LED_GetBright(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = led.PerformCommand("LED_GetBright");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //校正时间，以当前计算机的系统时间校正控制卡的时钟
        public object LED_AdjustTime(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AdjustTime");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //校正时间扩展，以指定的时间校正控制卡的时钟
        public object LED_AdjustTimeEx(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AdjustTime");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //发送节目数据 index为MakeRoot、MakeChapter、MakeRegion、MakeLeaf、MakeObject函数的返回值
        public object LED_SendToScreen(int nLEDID, Int32 index,Int32 zip)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_SendToScreen", index,zip);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置UDP通讯的参数
        public object LED_UDP_SenderParam(int nLEDID, Int32 param_index, Int32 locport, string host, Int32 rmtport, Int32 address, Int32 notifymode, Int32 wmhandle, Int32 wmmessage)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_UDP_SenderParam", param_index, locport, host, rmtport, address, notifymode, wmhandle, wmmessage);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置串口通讯的参数
        public object LED_COM_SenderParam(int nLEDID, Int32 param_index, Int32 comport, Int32 baudrate, Int32 address, Int32 notifymode, Int32 wmhandle, Int32 wmmessage)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_COM_SenderParam", param_index, comport, baudrate, address, notifymode, wmhandle, wmmessage);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //发送节目数据 index为MakeRoot、MakeChapter、MakeRegion、MakeLeaf、MakeObject函数的返回值
        public object LED_SendToScreen2(int nLEDID, Int32 param_index, Int32 index)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_SendToScreen2", param_index, index);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //压缩数据
        public object LED_Compress(int nLEDID, Int32 param_index)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_Compress", param_index);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //控制卡参数读取和设置相关API
        //读取控制卡参数，读取到的结果保存到动态链接库中
        public object LED_Cache_GetBoardParam(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_Cache_GetBoardParam");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_Cache_GetBoardParam2(int nLEDID,Int32 param_index)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_Cache_GetBoardParam2", param_index);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //设置控制卡参数
        public object LED_Cache_SetBoardParam(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_Cache_SetBoardParam");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        } 
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //读取控制卡当前显示内容相关API

        //读取控制卡当前显示内容

        public object LED_GetPlayContent(int nLEDID)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_GetPlayContent");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        //节目数据组织形式
        //  ROOT
        //   |
        //   |---Chapter(节目)
        //   |      |
        //   |      |---Region(区域/分区)
        //   |      |     |
        //   |      |     |---Leaf(页面)
        //   |      |     |    |
        //   |      |     |    |---Object(对象[文字、时钟、图片等])
        //   |      |     |    |
        //   |      |     |    |---Object(对象[文字、时钟、图片等])
        //   |      |     |    |
        //   |      |     |    |   ......
        //   |      |     |    |
        //   |      |     |
        //   |      |     |---Leaf(页面)
        //   |      |     |
        //   |      |     |   ......
        //   |      |     |
        //   |      |
        //   |      |---Region(区域/分区)
        //   |      |
        //   |      |   ......
        //   |      |
        //   |---Chapter(节目)
        //   |
        //   |   ......

        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        //设置显示屏旋转 
        //  rotate 旋转方式 =0不旋转 =1逆时针旋转90度 =2顺时针旋转90度
        //  metrix_width 显示屏宽度
        //  metrix_height 显示屏高度

        public object LED_SetRotate(int nLEDID,Int32 rotate, Int32 metrix_width, Int32 metrix_height)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_SetRotate", rotate, metrix_width, metrix_height);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //生成节目数据（从VisionShow软件编辑的Vsq文件载入，并生成要下发的节目数据）
        //  RootType 为节目类型；=ROOT_PLAY表示更新控制卡RAM中的节目(掉电丢失)；=ROOT_DOWNLOAD表示更新控制卡Flash中的节目(掉电不丢失)
        //  ColorMode 为颜色模式；取值为COLOR_MODE_MONO或者COLOR
        //  survive 为RAM节目生存时间，在RootType=ROOT_PLAY时有效，当RAM节目播放达到时间后，恢复显示FLASH中的节目
        //  filename 由VisionShow软件编辑的节目文件
        public object LED_MakeFromVsqFile(int nLEDID, string filename, Int32 RootType, Int32 ColorMode, Int32 survive)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_MakeFromVsqFile",filename,RootType,ColorMode,survive);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //生成节目数据
        //  RootType 为节目类型；=ROOT_PLAY表示更新控制卡RAM中的节目(掉电丢失)；=ROOT_DOWNLOAD表示更新控制卡Flash中的节目(掉电不丢失)
        //  ColorMode 为颜色模式；取值为COLOR_MODE_MONO或者COLOR
        //  survive 为RAM节目生存时间，在RootType=ROOT_PLAY时有效，当RAM节目播放达到时间后，恢复显示FLASH中的节目

        public object LED_MakeRoot(int nLEDID, string RootType, string ColorMode, string survive)
         {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_MakeRoot", RootType, ColorMode, survive);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_MakeObject(int nLEDID,string RootType, string ActionMode, Int32 ChapterIndex, Int32 RegionIndex, Int32 LeafIndex, Int32 ObjectIndex, string ColorMode)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_MakeObject", RootType, ActionMode, ChapterIndex, RegionIndex, LeafIndex, ObjectIndex, ColorMode);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        } 
        
        //生成节目数据，后续需要调用[AddRegion]->[AddLeaf]->[AddObject]->[AddWindows/AddDateTime等]
        //  RootType 必须设为ROOT_PLAY_CHAPTER
        //  ActionMode 必须设为0
        //  ChapterIndex 要更新的节目序号
        //  ColorMode 同MakeRoot中的定义
        //  time 播放的时间长度
        //  wait 等待模式，=WAIT_CHILD，表示当达到播放时间长度时，需要等待子节目播放完成再切换；
        //                 =WAIT_USE_TIME，表示当达到播放时间长度时，不等待子节目播放完成，直接切换下一节目

        public object LED_MakeChapter(int nLEDID, string RootType, string ActionMode, Int32 ChapterIndex, string ColorMode, UInt32 time, string wait)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_MakeChapter", RootType, ActionMode, ChapterIndex, ColorMode, time, wait);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //生成区域/分区，后续需要调用[AddLeaf]->[AddObject]->[AddWindows/AddDateTime等]
        //  RootType 必须设为ROOT_PLAY_REGION
        //  ActionMode 必须设为0
        //  ChapterIndex 要更新的节目序号
        //  RegionIndex 要更新的区域/分区序号
        //  ColorMode 同MakeRoot中的定义
        //  left、top、width、height 左、上、宽度、高度
        //  border 流水边框

        public object LED_MakeRegion(int nLEDID,Int32 RootType, Int32 ActionMode, Int32 ChapterIndex, Int32 RegionIndex,
            Int32 ColorMode, Int32 left, Int32 top, Int32 width, Int32 height, Int32 border)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_MakeRegion", RootType, ActionMode, ChapterIndex, RegionIndex, ColorMode, left, top, width, height, border);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //生成页面，后续需要调用[AddObject]->[AddWindows/AddDateTime等]
        //  RootType 必须设为ROOT_PLAY_LEAF
        //  ActionMode 必须设为0
        //  ChapterIndex 要更新的节目序号
        //  RegionIndex 要更新的区域/分区序号
        //  LeafIndex 要更新的页面序号
        //  ColorMode 同MakeRoot中的定义
        //  time 播放的时间长度
        //  wait 等待模式，=WAIT_CHILD，表示当达到播放时间长度时，需要等待子节目播放完成再切换；
        //                 =WAIT_USE_TIME，表示当达到播放时间长度时，不等待子节目播放完成，直接切换下一页面
        public object LED_MakeLeaf(int nLEDID, string RootType, string ActionMode, Int32 ChapterIndex, Int32 RegionIndex, Int32 LeafIndex,
           string ColorMode, UInt32 time, string wait)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_MakeLeaf", RootType, ActionMode, ChapterIndex, RegionIndex, LeafIndex, ColorMode, time, wait);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //生成播放对象，后续需要调用[AddWindows/AddDateTime等]
        //  RootType 必须设为ROOT_PLAY_LEAF
        //  ActionMode 必须设为0
        //  ChapterIndex 要更新的节目序号
        //  RegionIndex 要更新的区域/分区序号
        //  LeafIndex 要更新的页面序号
        //  ObjectIndex 要更新的对象序号
        //  ColorMode 同MakeRoot中的定义
        public object LED_MakeObject(int nLEDID, Int32 RootType, Int32 ActionMode, Int32 ChapterIndex, Int32 RegionIndex, Int32 LeafIndex, Int32 ObjectIndex, Int32 ColorMode)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_MakeObject", RootType, ActionMode, ChapterIndex, RegionIndex, LeafIndex, ObjectIndex, ColorMode);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //添加节目
        //  num 节目数据缓冲区编号，是MakeRoot的返回值
        //  time 播放的时间长度(单位为毫秒)
        //  wait 等待模式，=WAIT_CHILD，表示当达到播放时间长度时，需要等待子节目播放完成再切换；
        //                 =WAIT_USE_TIME，表示当达到播放时间长度时，不等待子节目播放完成，直接切换下一节目
        public object LED_AddChapter(int nLEDID, ushort num, UInt32 time, string wait)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddChapter", num, time, wait);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //添加节目
        //  num 节目数据缓冲区编号，是MakeRoot的返回值
        //  time 播放的时间长度(单位为毫秒)
        //  wait 等待模式，=WAIT_CHILD，表示当达到播放时间长度时，需要等待子节目播放完成再切换；
        //                 =WAIT_USE_TIME，表示当达到播放时间长度时，不等待子节目播放完成，直接切换下一节目
        //  kind 播放计划类型，=0始终播放，=1按照一周每日时间播放，=2按照指定起止日期时间播放，=3不播放
        //  week 一周有效日期，bit0到bit6表示周日到周六有效，当kind=1时，本参数起作用
        //  fromtime 有效起始时间
        //  totime 有效结束时间
        public object LED_AddChapterEx(int nLEDID, ushort num, UInt32 time, string wait, ushort kind, ushort week, Int32 stime,Int32 sdate,Int32 etime,Int32 edate)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddChapterEx", num, time, wait, kind, week, stime, sdate, etime, edate);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //添加区域/分区
        //  num 节目数据缓冲区编号，是MakeRoot、MakeChapter的返回值
        //  left、top、width、height 左、上、宽度、高度
        //  border 流水边框
        public object LED_AddRegion(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 border)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddRegion", num, left, top, width, height, border);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //添加页面
        //  num 节目数据缓冲区编号，是MakeRoot、MakeChapter、MakeRegion的返回值
        //  time 播放的时间长度(单位为毫秒)
        //  wait 等待模式，=WAIT_CHILD，表示当达到播放时间长度时，需要等待子节目播放完成再切换；
        //                 =WAIT_USE_TIME，表示当达到播放时间长度时，不等待子节目播放完成，直接切换下一页面
        public object LED_AddLeaf(int nLEDID, ushort num, UInt32 time, string wait)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddLeaf", num, time, wait);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        //添加日期时间显示
        //  num 节目数据缓冲区编号，是MakeRoot、MakeChapter、MakeRegion、MakeLeaf、MakeObject的返回值
        //  left、top、width、height 左、上、宽度、高度
        //  transparent 是否透明 =1表示透明；=0表示不透明
        //  border 流水边框(未实现)
        //  fontname 字体名称
        //  fontsize 字体大小
        //  fontcolor 字体颜色
        //  fontstyle 字体样式 举例：=WFS_BOLD表示粗体；=WFS_ITALIC表示斜体；=WFS_BOLD+WFS_ITALIC表示粗斜体
        //  year_offset 年偏移量
        //  month_offset 月偏移量
        //  day_offset 日偏移量
        //  sec_offset 秒偏移量
        //  format 显示格式 
        //      #y表示年 #m表示月 #d表示日 #h表示时 #n表示分 #s表示秒 #w表示星期 #c表示农历
        //      举例： format="#y年#m月#d日 #h时#n分#s秒 星期#w 农历#c"时，显示为"2009年06月27日 12时38分45秒 星期六 农历五月初五"
        public object LED_AddDateTime(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border,
           string fontname, Int32 fontsize, Int32 fontcolor, Int32 fontstyle,
           Int32 year_offset, Int32 month_offset, Int32 day_offset, Int32 sec_offset, string format)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddDateTime", num, left, top, width, height, transparent, border,
            fontname,  fontsize,  fontcolor,  fontstyle,
            year_offset,  month_offset,  day_offset,  sec_offset,  format);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //添加日期时间显示
        //  num 节目数据缓冲区编号，是MakeRoot、MakeChapter、MakeRegion、MakeLeaf、MakeObject的返回值
        //  left、top、width、height 左、上、宽度、高度
        //  transparent 是否透明 =1表示透明；=0表示不透明
        //  border 流水边框(未实现)
        //  vertical 是否纵向显示 =0正常 =1逆时针旋转纵向显示 =2顺时针旋转纵向显示
        //  fontname 字体名称
        //  fontsize 字体大小
        //  fontcolor 字体颜色
        //  fontstyle 字体样式 举例：=WFS_BOLD表示粗体；=WFS_ITALIC表示斜体；=WFS_BOLD+WFS_ITALIC表示粗斜体
        //  year_offset 年偏移量
        //  month_offset 月偏移量
        //  day_offset 日偏移量
        //  sec_offset 秒偏移量
        //  format 显示格式 
        //      #y表示年 #m表示月 #d表示日 #h表示时 #n表示分 #s表示秒 #w表示星期 #c表示农历
        //      举例： format="#y年#m月#d日 #h时#n分#s秒 星期#w 农历#c"时，显示为"2009年06月27日 12时38分45秒 星期六 农历五月初五"
        public object LED_AddDateTimeEx(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border, Int32 vertical,
           string fontname, Int32 fontsize, Int32 fontcolor, string fontstyle, Int32 year_offset, Int32 month_offset, Int32 day_offset, Int32 sec_offset, string format)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddDateTimeEx", num, left, top, width, height, transparent, border, vertical, fontname, fontsize, fontcolor, fontstyle, year_offset, month_offset, day_offset, sec_offset, format);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        //添加作战时间显示
        //  num 节目数据缓冲区编号，是MakeRoot、MakeChapter、MakeRegion、MakeLeaf、MakeObject的返回值
        //  left、top、width、height 左、上、宽度、高度
        //  transparent 是否透明 =1表示透明；=0表示不透明
        //  border 流水边框(未实现)
        //  fontname 字体名称
        //  fontsize 字体大小
        //  fontcolor 字体颜色
        //  fontstyle 字体样式 举例：=WFS_BOLD表示粗体；=WFS_ITALIC表示斜体；=WFS_BOLD+WFS_ITALIC表示粗斜体
        //  format 显示格式 
        //      #y表示年 #m表示月 #d表示日 #h表示时 #n表示分 #s表示秒 #w表示星期
        //  basetime 作战时间
        //  fromtime 开始时间
        //  totime 结束时间
        //  step 计时走秒时间步长（多少毫秒走一秒）
        public object LED_AddCampaignEx(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border,
           string fontname, Int32 fontsize, Int32 fontcolor, Int32 fontstyle,
           string format, Int32 btime,Int32 bdate,Int32 stime,Int32 sdate,Int32 ttime,Int32 tdate, Int32 step)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddCampaignEx", num, left, top, width, height, transparent, border, fontname, fontsize, fontcolor, fontstyle, format, btime, bdate, stime, sdate, ttime, tdate, step);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        } 
        public object LED_AddCounter(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border, Int32 countertype, Int32 format,
           string fontname, Int32 fontsize, Int32 fontcolor, Int32 fontstyle, Int32 btime,Int32 bdate)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddCounter", num, left, top, width, height, transparent, border, countertype, format, fontname, fontsize, fontcolor, fontstyle, btime, bdate);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        public object LED_AddClock(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border, Int32 offset,
           UInt32 bkcolor, UInt32 bordercolor, UInt32 borderwidth, Int32 bordershape,
           Int32 dotradius, Int32 adotwidth, UInt32 adotcolor, Int32 bdotwidth, UInt32 bdotcolor,
           Int32 hourwidth, UInt32 hourcolor, Int32 minutewidth, UInt32 minutecolor, Int32 secondwidth, UInt32 secondcolor)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddClock", num, left, top, width, height, transparent, border, offset,
            bkcolor,  bordercolor,  borderwidth,  bordershape,
            dotradius,  adotwidth,  adotcolor,  bdotwidth,  bdotcolor,
            hourwidth,  hourcolor,  minutewidth,  minutecolor,  secondwidth,  secondcolor);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

     
        public object LED_AddClockEx2(int nLEDID,ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border, Int32 vertical, Int32 offset,
           UInt32 bkcolor, UInt32 bordercolor, UInt32 borderwidth, string bordershape,
           Int32 dotradius, Int32 adotwidth, UInt32 adotcolor, Int32 bdotwidth, UInt32 bdotcolor,
           UInt32 cdotvisible, Int32 cdotwidth, UInt32 cdotcolor,
           Int32 hourwidth, UInt32 hourcolor, Int32 minutewidth, UInt32 minutecolor, Int32 secondwidth, UInt32 secondcolor)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddClockEx2", num, left, top, width, height, transparent, border, vertical, offset, bkcolor, bordercolor, borderwidth, bordershape, dotradius, adotwidth, adotcolor, bdotwidth, bdotcolor,
            cdotvisible,  cdotwidth,  cdotcolor,hourwidth,  hourcolor,  minutewidth,  minutecolor,  secondwidth,  secondcolor);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddMovie(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border, string filename, Int32 stretch)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddMovie", num, left, top, width, height, transparent, border, filename, stretch);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        } 
 
        public object LED_AddWindows(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddWindows", num, left, top, width, height, transparent, border);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddChildWindow(int nLEDID,ushort num, UInt32 dc, Int32 width, Int32 height, Int32 alignment,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddChildWindow", num, dc, width, height, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddChildPicture(int nLEDID,ushort num, string filename, Int32 alignment,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddChildPicture", num, filename, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        public object LED_AddChildText(int nLEDID,ushort num, string str, string fontname, Int32 fontsize, Int32 fontcolor, Int32 fontstyle, Int32 wordwrap, Int32 alignment,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddChildText", num, str, fontname, fontsize, fontcolor, fontstyle, wordwrap, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddChildTextEx(int nLEDID, ushort num, string str, string fontname, Int32 fontsize, Int32 fontcolor, Int32 fontstyle, Int32 autofitsize, Int32 wordwrap, Int32 vertical, Int32 alignment, Int32 verticalspace, Int32 horizontalfit,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddChildTextEx", num, str, fontname, fontsize, fontcolor, fontstyle, autofitsize, wordwrap, vertical, alignment, verticalspace, horizontalfit,
            inmethod,  inspeed,  outmethod,  outspeed,  stopmethod,  stopspeed,  stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        public object LED_AddStrings(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddStrings", num, left, top, width, height, transparent, border);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddChildString(int nLEDID, ushort num, string str, Int32 fontset, Int32 color,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddChildString", num, str, fontset, color, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        } 
 
        public object LED_AddWindow(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border,
           string picture, Int32 src_width, Int32 src_height, Int32 alignment,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddWindow", num, left, top, width, height, transparent, border,
           picture, src_width, src_height, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddPicture(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border, string filename, Int32 alignment,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddPicture", num, left, top, width, height, transparent, border, filename, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddTable(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, string profile, string content,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddTable", num, left, top, width, height, transparent, profile, content, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        public object LED_AddText(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border,
           string str, string fontname, Int32 fontsize, Int32 fontcolor, string fontstyle, Int32 wordwrap, Int32 alignment,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddText", num, left, top, width, height, transparent, border, str, fontname, fontsize, fontcolor, fontstyle, wordwrap, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        public object LED_AddTextEx3(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 flag,
           string str, string fontname, Int32 fontsize, Int32 fontcolor, string fontstyle, Int32 bkcolor, Int32 autofitsize, Int32 wordwrap,
           Int32 vertical, Int32 alignment, Int32 verticalspace, Int32 horizontalfit,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddTextEx3", num, left, top, width, height, transparent, flag,
           str, fontname, fontsize, fontcolor, fontstyle, bkcolor, autofitsize, wordwrap,vertical,  alignment,  verticalspace,  horizontalfit,inmethod,  inspeed,  outmethod,  outspeed,  stopmethod,  stopspeed,  stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        public object LED_AddString(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border,
           string str, Int32 fontset, Int32 color,
           Int32 inmethod, Int32 inspeed, Int32 outmethod, Int32 outspeed, Int32 stopmethod, Int32 stopspeed, Int32 stoptime)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddString", num, left, top, width, height, transparent, border, str, fontset, color, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        //添加温度显示
        //  num 节目数据缓冲区编号，是MakeRoot、MakeChapter、MakeRegion、MakeLeaf、MakeObject的返回值
        //  left、top、width、height 左、上、宽度、高度
        //  transparent 是否透明 =1表示透明；=0表示不透明
        //  border 流水边框(未实现)
        //  fontname 字体名称
        //  fontsize 字体大小
        //  fontcolor 字体颜色
        //  fontstyle 字体样式 举例：=WFS_BOLD表示粗体；=WFS_ITALIC表示斜体；=WFS_BOLD+WFS_ITALIC表示粗斜体
        public object LED_AddTemperature(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border,
           string fontname, Int32 fontsize, Int32 fontcolor, Int32 fontstyle)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddTemperature", num, left, top, width, height, transparent, border, fontname, fontsize, fontcolor, fontstyle);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }

        public object LED_AddHumidity(int nLEDID, ushort num, Int32 left, Int32 top, Int32 width, Int32 height, Int32 transparent, Int32 border,
           string fontname, Int32 fontsize, Int32 fontcolor, Int32 fontstyle)
        {
            object result = 0;
            LEDUnit2 led = null;
            try
            {
                led = GetLED(nLEDID);
                if (led == null)
                    return result;
                result = (object)led.PerformCommand("LED_AddHumidity", num, left, top, width, height, transparent, border, fontname, fontsize, fontcolor, fontstyle);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        } 
    }
}
